package CI;

import java.util.ArrayList;
import java.util.Scanner;

public class REPL {
	public static void main(String args[]) {
		evalLoop();
	}
	public static void evalLoop() {
		Scanner input = new Scanner(System.in);
		Environment env = new Environment(null);
		while (true) {
			System.out.print("Charm>");
			String code = input.nextLine();
			if (code.equals("quit")) {
				break;
			}			
			try {			
				ArrayList<Object> parseResult = Parser.parse(code);
				
				for (int i=0; i<parseResult.size(); i++) {
					System.out.println(Evaluator.meval(parseResult.get(i),env));
				}
			}
			catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
	}
}
